﻿@using DLULearningNetworkModel;
@using DLULearningNetwork.Libs;
@model DLULearningNetworkModel.Feed
@{
    DLULearningNetworkModel.Account currentUser = DLULearningNetwork.ActionFilterAttributes.RequireUserLogin.LoginUser;
    Layout = null;    
}
@if (Model.Type_s == EnumFeedType.PostOnWall.ToString())
{
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail">
        <div class="wallDetail-l">
            <a class="avt" style="color: green;" href="/UserPage/UserHome/@Model.AccountReference.Value.Nickname_s">
                @if (!string.IsNullOrEmpty(Model.AccountReference.Value.Avatar_s))
                {
                    <img alt="avatar" src="@Url.Content(Model.AccountReference.Value.Avatar_s.Replace("Original", "Small"))" />
                }
                else
                { 
                    <img alt="avatar" src="@Url.Content("~/Content/Images/avatar.gif")" />
                }
            </a>
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || Model.PassiveAccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a> 
                }
                @if (Model.ActiveAccountID_u == Model.PassiveAccountID_u)
                {
                    <a class="avt" style="color:green;" href="/UserPage/UserHome/@Model.AccountReference.Value.Nickname_s">
                        <strong>@Model.AccountReference.Value.LastName_s
                            @Model.AccountReference.Value.FirstName_s
                        </strong></a>
                    <br />
                    <span>@MvcHtmlString.Create(Model.Content_s.Replace("\\n", "<br>")) </span>
                }
                else
                {
                    <a class="avt" style="color:green;" href="/UserPage/UserHome/@Model.AccountReference.Value.Nickname_s">
                        <strong>@Model.AccountReference.Value.LastName_s
                            @Model.AccountReference.Value.FirstName_s</strong></a> 
                    <span style="color: green;">» </span>
                    <a class="avt" style="color:green;" href="/UserPage/UserHome/@Model.Account1Reference.Value.Nickname_s">
                        <strong>@Model.Account1Reference.Value.LastName_s
                            @Model.Account1Reference.Value.FirstName_s</strong></a>
                    <br />
                    <span>@MvcHtmlString.Create(Model.Content_s.Replace("\\n", "<br>")) </span>
                }
            </div>
            <div class="actlink">
                <span class="grey">@Html.TimePost(Model.CreateDate_dt) </span><span class="icodot">
                </span><span class="grey">Số bình luận : </span><span class="grey">@Model.FeedComments.Count</span>
            </div>
        </div>
    </div>
    <div class="childComment" name="childComments" feedID="@Model.FeedID_u" totalcomment="@Model.FeedComments.Count">
        @{
                List<DLULearningNetworkModel.FeedComment> fcmts = Model.FeedComments.OrderByDescending(fc => fc.CreateDate_dt).Skip(0).Take(2).OrderBy(fc => fc.CreateDate_dt).ToList();
        }
        @if (fcmts.Count > 0)
        {
            if (fcmts.Count < Model.FeedComments.Count)
            { <div class="row-comment">
                <a href="#" name="moreFeedComment" loaded="@fcmts.Count" onclick="return false;"
        class="moreCom">Xem thêm lời bình luận</a>
                <img name="loadingimage" src="../../Content/Images/loadingimage.gif" alt="" style="display: none;
                    padding-left: 20px;" />
            </div> }
        }
        <div class="row-comment" name="anchor_Head" style="display: none;">
        </div>
        @if (fcmts.Count > 0)
        {
            foreach
                (DLULearningNetworkModel.FeedComment fcmt in fcmts)
            {
            @Html.Partial("FeedComment", fcmt) 
            }
        }
        <div class="row-comment" name="anchor_Tail" style="display: none;">
        </div>
        @if (ViewBag.AllowComment != null)
        {
            <div name="cmtbox" class="row-comment" style="display: none;">
                <div id="avt_ID" class="rowcomlt">
                    @if (!string.IsNullOrEmpty(currentUser.Avatar_s))
                    { 
                        <img src="@Url.Content(currentUser.Avatar_s.Replace("Original", "Small"))" /> 
                    }
                    else
                    { 
                        <img alt="avatar" src="@Url.Content("~/Content/Images/avatar.gif")"/> 
                    }
                </div>
                <div class="wrcomtxterae">
                    <textarea id="@{string s = "textComment_" + Model.FeedID_u.ToString(); @s}" name="txtComment">
                </textarea>
                </div>
                <div class="ctnbtn">
                    <div class="cmttip">
                    </div>
                    <a href="#" name="submitComment" class="dlubtn" style="margin: 5px 5px 5px auto"
                        onclick="return false;">Bình luận</a>
                    <div class="clr">
                    </div>
                </div>
            </div>
            <div class="row-comment" style="display: block">
                <div name="virtualbox" class="wrtcom tmpTxt">
                    Nhập lời bình</div>
            </div>
        }
    </div>
}
else
{
    if (Model.Type_s == EnumFeedType.ActivityComment.ToString())
    { 
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail" style="padding-bottom:8px;">
        <div class="wallDetail-l">
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a>
                }
                <span>Hoạt động gần đây </span><span class="grey">@Html.TimePost(Model.CreateDate_dt)
                </span><span class="icodot"></span>
                <br />
                <img src="../../Content/Images/comment30.png" style="float: left; border: 0; width: 25px;
                    padding-right: 3px;" />
                @if (Model.FeedCommentReference.Value.FeedReference.Value.ActiveAccountID_u == currentUser.AccountID_u)
                { 
                    <span>bình luận </span> <a href="/Feed/Detail/@Model.FeedCommentReference.Value.Feed.FeedID_u" style="color:green">bài
                        viết</a>
                    <span>của mình trên tường </span>
                    if (Model.FeedCommentReference.Value.FeedReference.Value.CourseID_u != null)
                    {
                    <a href="/Course/Wall/@Model.FeedCommentReference.Value.FeedReference.Value.CourseID_u" style="color:Green;">
                        <strong>lớp @Model.FeedCommentReference.Value.FeedReference.Value.CourseReference.Value.Title_s</strong></a>
                    }
                    else
                    {
                        if (Model.FeedCommentReference.Value.FeedReference.Value.PassiveAccountID_u != null)
                        { 
                    <a href="/UserPage/UserHome/@Model.FeedCommentReference.Value.FeedReference.Value.PassiveAccountID_u">@Model.FeedCommentReference.Value.FeedReference.Value.Account1Reference.Value.LastName_s
                        @Model.FeedCommentReference.Value.FeedReference.Value.Account1Reference.Value.FirstName_s</a>
                        }
                    }
                }
                else
                {
                    if (Model.FeedCommentReference.Value.FeedReference.Value.ActiveAccountID_u != Model.FeedCommentReference.Value.FeedReference.Value.PassiveAccountID_u)
                    {
                    <span>bình luận </span> <a href="/Feed/Detail/@Model.FeedCommentReference.Value.Feed.FeedID_u" style="color:green">bài
                        viết</a>
                    <span>của </span> <a href="@Model.FeedCommentReference.Value.Feed.ActiveAccountID_u" style="color:green"><strong>@Model.FeedCommentReference.Value.Feed.Account.LastName_s
                        @Model.FeedCommentReference.Value.Feed.Account.FirstName_s</strong></a>
                    <span>trên tường </span>
                        if (Model.FeedCommentReference.Value.FeedReference.Value.CourseID_u != null)
                        {
                    <a href="/Course/Wall/@Model.FeedCommentReference.Value.FeedReference.Value.CourseID_u" style="color:green">
                        <strong>lớp @Model.FeedCommentReference.Value.FeedReference.Value.Course.Title_s</strong></a>
                        }
                        else
                        {
                            if (Model.FeedCommentReference.Value.FeedReference.Value.PassiveAccountID_u != null)
                            { 
                    <a href="/UserPage/UserHome/@Model.FeedCommentReference.Value.FeedReference.Value.PassiveAccountID_u" style="color:green">
                        <strong>@Model.FeedCommentReference.Value.Feed.Account1Reference.Value.LastName_s
                            @Model.FeedCommentReference.Value.Feed.Account1Reference.Value.FirstName_s</strong></a>
                            }
                        }
                    }
                    else
                    {
                    <span>bình luận</span> <a href="/Feed/Detail/@Model.FeedCommentReference.Value.Feed.FeedID_u" style="color:Green;">bài
                        viết</a>
                    <span>trên tường của chính</span>
                    <a href="/UserPage/UserHome/@Model.FeedCommentReference.Value.FeedReference.Value.ActiveAccountID_u" style="color:green">
                        <strong>@Model.FeedCommentReference.Value.FeedReference.Value.AccountReference.Value.LastName_s
                            @Model.FeedCommentReference.Value.FeedReference.Value.AccountReference.Value.FirstName_s</strong></a>
                    }
                }
                <span>"@MvcHtmlString.Create(Model.Content_s.Replace("\\n", "<br>"))"</span>
            </div>
        </div>
    </div>
    }
    else
    {
        if (Model.Type_s == EnumFeedType.ActivityMakeFriend.ToString())
        { 
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail" style="padding-bottom:8px;">
        <div class="wallDetail-l">
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || Model.PassiveAccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a>
                }
                <span>Hoạt động gần đây </span><span class="grey">@Html.TimePost(Model.CreateDate_dt)
                </span>
                <br />
                <img src="../../Content/Images/MakeFriend30.png" style="float: left; border: 0; width: 25px;
                    padding-right: 3px;" />
                <a class="avt" style="color:green;" href="/UserPage/UserHome/@Model.AccountReference.Value.Nickname_s">
                    <strong>@Model.AccountReference.Value.LastName_s
                        @Model.AccountReference.Value.FirstName_s</strong></a> <span>đã kết bạn với</span><a class="avt" style="color:green;" href="/UserPage/UserHome/@Model.Account1Reference.Value.Nickname_s">
                            <strong>@Model.Account1Reference.Value.LastName_s
                                @Model.Account1Reference.Value.FirstName_s</strong></a>
            </div>
        </div>
    </div>
        }
        else
        {
            if (Model.Type_s == EnumFeedType.PostOnCourseWall.ToString())
            {
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail">
        <div class="wallDetail-l">
            <a class="avt" href="/UserPage/UserHome/@Model.AccountReference.Value.Nickname_s">
                @if (!string.IsNullOrEmpty(Model.AccountReference.Value.Avatar_s))
                {
                    <img alt="avatar" src="@Url.Content(Model.AccountReference.Value.Avatar_s.Replace("Original", "Small"))" />
                }
                else
                { 
                    <img alt="avatar" src="@Url.Content("~/Content/Images/avatar.gif")" />
                }
            </a>
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || Model.CourseReference.Value.AccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a> 
                }
                <a class="avt" style="color:green;" href="/UserPage/UserHome/@Model.AccountReference.Value.Nickname_s">
                    <strong>@Model.AccountReference.Value.LastName_s
                        @Model.AccountReference.Value.FirstName_s</strong></a> <span style="color: Green">»
                        </span>@*Undone : url lop hoc tuong ung*@ <a class="avt" style="color:green;" href="/Course/Wall/@Model.CourseReference.Value.CourseID_u">
                            <strong>lớp @Model.CourseReference.Value.Title_s</strong></a>
                <br />
                <span>@MvcHtmlString.Create(Model.Content_s.Replace("\\n", "<br>"))
                </span>
            </div>
            <div class="actlink">
                <span class="grey">@Html.TimePost(Model.CreateDate_dt) </span><span class="icodot">
                </span><span class="grey">Số bình luận : </span><span class="grey">@Model.FeedComments.Count</span>
            </div>
        </div>
    </div>
    <div class="childComment" name="childComments" feedID="@Model.FeedID_u" totalcomment="@Model.FeedComments.Count">
        @{
                List<DLULearningNetworkModel.FeedComment> fcmts = Model.FeedComments.OrderByDescending(fc => fc.CreateDate_dt).Skip(0).Take(2).OrderBy(fc => fc.CreateDate_dt).ToList();
        }
        @if (fcmts.Count > 0)
        {
            if (fcmts.Count < Model.FeedComments.Count)
            { <div class="row-comment">
                <a href="#" name="moreFeedComment" loaded="@fcmts.Count" onclick="return false;" class="moreCom">
                    Xem thêm lời bình luận </a>
                <img name="loadingimage" src="../../Content/Images/loadingimage.gif" alt="" style="display: none;
                    padding-left: 20px;" />
            </div> 
            }
        }
        <div class="row-comment" name="anchor_Head" style="display: none;">
        </div>
        @if (fcmts.Count > 0)
        {
            foreach
                (DLULearningNetworkModel.FeedComment fcmt in fcmts)
            {
            @Html.Partial("FeedComment", fcmt) 
            }
        }
        <div class="row-comment" name="anchor_Tail" style="display: none;">
        </div>
        @if (ViewBag.AllowComment != null)
        {
            <div name="cmtbox" class="row-comment" style="display: none;">
                <div id="avt_ID" class="rowcomlt">
                    @if (!string.IsNullOrEmpty(currentUser.Avatar_s))
                    { 
                        <img src="@Url.Content(currentUser.Avatar_s.Replace("Original", "Small"))" /> 
                    }
                    else
                    { 
                        <img alt="avatar" src="@Url.Content("~/Content/Images/avatar.gif")"/> 
                    }
                </div>
                <div class="wrcomtxterae">
                    <textarea id="@{string s = "textComment_" + Model.FeedID_u.ToString(); @s}" name="txtComment">
                </textarea>
                </div>
                <div class="ctnbtn">
                    <div class="cmttip">
                    </div>
                    <a href="#" name="submitComment" class="dlubtn" style="margin: 5px 5px 5px auto"
                        onclick="return false;">Bình luận</a>
                    <div class="clr">
                    </div>
                </div>
            </div>
            <div class="row-comment" style="display: block">
                <div name="virtualbox" class="wrtcom tmpTxt">
                    Nhập lời bình</div>
            </div>
        }
    </div>
            }
            else
            {
                if (Model.Type_s == EnumFeedType.ActivityPostOnWallFriend.ToString())
                { 
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail" style="padding-bottom:8px;">
        <div class="wallDetail-l">
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a>
                }
                <span>Hoạt động gần đây </span><span class="grey">@Html.TimePost(Model.CreateDate_dt)
                </span><span class="icodot"></span>
                <br />
                <img src="../../Content/Images/post30.png" style="float: left; border: 0; width: 25px;
                    padding-right: 3px;" />
                viết lên <a href="/Feed/Detail/@StringHelper.GetGuidFromContent(Model.Content_s)" style="color:Green;">
                    tường</a> <span style="color: Green">» </span><a class="avt" style="color:green;" href="/UserPage/UserHome/@Model.Account1Reference.Value.Nickname_s">
                        <strong>@Model.Account1Reference.Value.LastName_s
                            @Model.Account1Reference.Value.FirstName_s</strong></a><br />
                <span>"@MvcHtmlString.Create(StringHelper.GetContentFromContent(Model.Content_s).Replace("\\n", "<br>"))"</span>
            </div>
        </div>
    </div>
                }
                else
                {
                    if (Model.Type_s == EnumFeedType.ActivityPostOnCourseWall.ToString() && Model.Course.IsBanned_b == false)
                    {
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail" style="padding-bottom:8px;">
        <div class="wallDetail-l">
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a>
                }
                <span>Hoạt động gần đây </span><span class="grey">@Html.TimePost(Model.CreateDate_dt)
                </span><span class="icodot"></span>
                <br />
                <img src="../../Content/Images/post30.png" style="float: left; border: 0; width: 25px;
                    padding-right: 3px;" />
                viết lên <a href="/Feed/Detail/@StringHelper.GetGuidFromContent(Model.Content_s)" style="color:Green;">
                    tường</a> của lớp <a class="avt" style="color:green;" href="/Course/wall/@Model.CourseID_u">
                        <strong>@Model.CourseReference.Value.Title_s</strong></a> <span>"@MvcHtmlString.Create(StringHelper.GetContentFromContent(Model.Content_s).Replace("\\n", "<br>"))"</span>
            </div>
        </div>
    </div>
                    }
                    else
                    {
                        if (Model.Type_s == EnumFeedType.ActivityChangeSeminarSchedule.ToString())
                        {
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail" style="padding-bottom:8px;">
        <div class="wallDetail-l">
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a>
                }
                <span>Hoạt động gần đây </span><span class="grey">@Html.TimePost(Model.CreateDate_dt)
                </span><span class="icodot"></span>
                <br />
                <img src="../../Content/Images/post30.png" style="float: left; border: 0; width: 25px;
                    padding-right: 3px;" />
                <span>"@MvcHtmlString.Create(StringHelper.GetContentFromContent(Model.Content_s).Replace("\\n", "<br>"))"</span>
                của
                @StringHelper.GetHtmlCourseName(Model.CourseReference.Value)
            </div>
        </div>
    </div>
                        }
                        else
                        {
                            if (Model.Type_s == EnumFeedType.ActivityChangeResourse.ToString())
                            { 
    <div name="feed" feedID="@Model.FeedID_u" class="wallDetail" style="padding-bottom:8px;">
        <div class="wallDetail-l">
        </div>
        <div class="wallDetail-r">
            <div class="message">
                @if (Model.ActiveAccountID_u == currentUser.AccountID_u || ViewBag.AllowDelete != null)
                {
                    <a name="deleteFeed" href="#" onclick="return false;" class="close" style="display: none;">
                    </a>
                }
                <span>Hoạt động gần đây </span><span class="grey">@Html.TimePost(Model.CreateDate_dt)
                </span><span class="icodot"></span>
                <br />
                <img src="../../Content/Images/post30.png" style="float: left; border: 0; width: 25px;
                    padding-right: 3px;" />
                <span>"@MvcHtmlString.Create(StringHelper.GetContentFromContent(Model.Content_s).Replace("\\n", "<br>"))"</span>
                của
                @StringHelper.GetHtmlCourseName(Model.CourseReference.Value)
            </div>
        </div>
    </div>
                            }
                        }
                    }
                }

            }
        }
    }
}